﻿'水平偏移统计表
Public Class clsSppyInfo
    Public Function insert(en As entity_sppyInfo) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer

        sql &= "INSERT INTO sf.b_prod_sppy_info( factory_id , prod_id , project_name , "
        sql &= "initial_spec , final_spec , model , check_date , horizontal_offset_Measured_value , horizontal_offset_Maximum , "
        sql &= "flb_side_length , inspector, note ,operator, update_time) "
        sql &= "VALUES ( ?, ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?,(SELECT CURRENT_TIMESTAMP(6)))"
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .factory_id, .prod_id, .project_name,
                                         .initial_spec, .final_spec, .model, .check_date, .horizontal_offset_Measured_value, .horizontal_offset_Maximum,
                                         .flb_side_length, .inspector, .note, .ope)
        End With
        Return rtn
    End Function

    Public Function update(en As entity_sppyInfo) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer

        sql &= " UPDATE sf.b_prod_sppy_info  "
        sql &= " SET prod_id = ? "
        sql &= " , project_name = ? "
        sql &= " , initial_spec = ? "
        sql &= " , final_spec = ? "
        sql &= " , model = ? "
        sql &= " , check_date = ? "
        sql &= " , horizontal_offset_Measured_value = ? "
        sql &= " , horizontal_offset_Maximum = ? "
        sql &= " , flb_side_length = ? "
        sql &= " , inspector = ? "
        sql &= " , note = ? "
        sql &= " , operator = ? "
        sql &= " , update_time = (SELECT CURRENT_TIMESTAMP(6)) "
        sql &= " WHERE sys_id = ? "
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .prod_id, .project_name,
                                         .initial_spec, .final_spec, .model, .check_date, .horizontal_offset_Measured_value,
                                         .horizontal_offset_Maximum, .flb_side_length, .inspector, .note, .ope, .sys_id)
        End With
        Return rtn
    End Function


    Public Function selectBySysid(_sysid As String) As DataTable
        Dim szSql As String = ""
        szSql &= "select * from sf.b_prod_sppy_info where factory_id=? and sys_id=?"

        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, g_factory_id, _sysid)
        If IsNothing(dt) Then
            selectBySysid = New DataTable
        Else
            selectBySysid = dt
        End If

    End Function

    Public Function selectAll(Optional prod_id As String = "", Optional project_name As String = "", Optional model As String = "", Optional check_date As String = "") As DataTable
        Dim szSql As String = ""
        szSql &= "select * from sf.b_prod_sppy_info where factory_id=? "
        If prod_id <> "" Then
            szSql &= " and prod_id like ('%" & prod_id & "%')"
        End If
        If project_name <> "" Then
            szSql &= " and project_name like ('%" & project_name & "%')"
        End If
        If model <> "全部" Then
            szSql &= " and model like ('%" & model & "%')"
        End If
        If check_date <> "" Then
            szSql &= " and check_date > '" & check_date & "'"
        End If

        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, g_factory_id)
        If IsNothing(dt) Then
            selectAll = New DataTable
        Else
            selectAll = dt
        End If

    End Function
End Class
